import java.util.*;

public class demo02 {

    public static void main(String[] args){
        // 完成Map集合案例：投票统计程序
        calc();
    }

    public static void calc(){
        List<String> locations = new ArrayList<>();
        String[] attractions = {"云台山","太行山","王屋山","嵩山"};
        Random r = new Random();
        for(int i = 1; i <= 80; i++){
            int index = r.nextInt(attractions.length);
            locations.add(attractions[index]);
        }
        System.out.println(locations);

        Map<String, Integer> map = new HashMap<>();
        for(String location : locations){
            if(map.containsKey(location)){
                map.put(location, map.get(location) + 1);
            }else {
                map.put(location, 1);
            }
        }
        System.out.println(map);
        for(Map.Entry<String, Integer> entry : map.entrySet()){
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }

    }
}
